
#include <assert.h>
#include "file_info.h++"

using namespace std;

void test_fileInfo();
void test_corpusInfo();

int main(int argc, const char** argv)
{

	test_fileInfo();
	test_corpusInfo();
	printf("test pass for file_info\n");
	
	return 0;
}

void test_fileInfo()
{
	FileInfo fi("test/test_file_info.txt");
	
	assert(fi.getOccurences("test") == 2);
	assert(fi.getOccurences("évaluer") == 1);
	assert(fi.getOccurences("evaluer") == 1);
	assert(fi.getOccurences("coup") == 0);
	
	assert(fi.getNumberOfDifferentWords() == 11);
	assert(fi.getNumberOfWords() == 13);

	assert(fi.getFilePath() == "test/test_file_info.txt");
}

void test_corpusInfo()
{
	vector<string> v;
	v.push_back("test/test_file_info.txt");
	v.push_back("test/test_file_info.txt");
	
	CorpusInfo ci(v);

	assert(ci.tf("test", 1) > (2. /13.) - 0.0001 && ci.tf("test", 1) < (2./13.) + 0.01);
	assert(ci.tf("evaluer", 0) > (1. /13.) - 0.0001 && ci.tf("evaluer", 0) < (1./13.) + 0.0001);
	assert(ci.tf("coup", 1) > (0.) - 0.0001 && ci.tf("coup", 1) < (0./13.) + 0.0001);

	assert(ci.idf("test") > 0. - 0.0001 && ci.idf("test") < 0. + 0.0001);

	assert(ci.tfIdf("coup", 0) == 0.);
	assert(ci.tfIdf("test", 1) == 0.);

}
